// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import VueRouter from 'vue-router'
import App from './App'
import axios from 'axios'
import Routes from './routes'

Vue.config.productionTip = false
Vue.prototype.$http = axios
//全局配置
axios.defaults.baseURL="https://jsonplaceholder.typicode.com"


Vue.use(VueRouter)
//自定义指令
//Vue.directive("titleColor",{ //自定义标题颜色
//	bind(el,binding,vnode){
//		el.style.color="#"+Math.random().toString(16).slice(2,8);
//	}
//});

Vue.directive("theme",{ //自定义宽度和背景色
	bind(el,binding,vnode){
		if(binding.value == "wide"){
			el.style.maxWidth="1260px";
		}else{
			el.style.maxWidth="560px";
		}
		
		if(binding.arg == "column"){
			el.style.background="green";
			el.style.padding="60px";
		}
		
	}
});

//自定义过滤器
//全局
//Vue.filter("to-uppercase",function(value){
//	return value.toUpperCase();
//})
Vue.filter("snippet",function(value){
	return value.slice(0,100)+"...";
})

//router路由
const router=new VueRouter({
	routes:Routes,
	mode:"history" 
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  components: { App },
  template: '<App/>',
  router:router
})
